import { Observer } from 'mobx-vue'
import { Component, Vue } from 'vue-property-decorator'
import { homeIndex } from 'src/utils/axios'
import ActivityAdd from 'src/views/operate-manage/components/activity-add/activity-add.vue'
import ActivityDetail from 'src/views/operate-manage/components/activity-detail/activity-detail.vue'
import ActivityEdit from 'src/views/operate-manage/components/activity-edit/activity-edit.vue'
require('./activity-list.scss')
@Observer
@Component({
  components: {
    ActivityAdd,
    ActivityDetail,
    ActivityEdit,
  },
})
export default class ActivityList extends Vue {
  // 分页
  page: number = 1
  pageNo: number = 1
  pageSize: number = 10
  count: number = 0
  //表格标题
  columns: any = [
    {
      align: 'center',
      title: 'ID',
      slot: 'id',
      width: 60,
    },
    {
      align: 'center',
      title: '活动名称',
      slot: 'name',
    },
    {
      align: 'center',
      title: '活动背景图',
      slot: 'img',
      width: 120,
    },
    {
      align: 'center',
      title: '活动链接',
      slot: 'url',
    },
    {
      align: 'center',
      title: '活动有效期',
      slot: 'data',
    },
    {
      align: 'center',
      title: '创建时间',
      slot: 'time',
    },
    {
      align: 'center',
      title: '状态',
      slot: 'zt',
      width: 80
    },
    {
      align: 'center',
      title: '操作',
      slot: 'action',
      width: 240
    },
  ]
  //表格假数据
  showData: any = [
    {
    },
    {
    }
  ]
  //添加活动弹出层
  isAdd: boolean = false
  //编辑活动弹出层
  isEdit: boolean = false
  editId: any = ''
  //详情活动弹出层
  isDetail: boolean = false
  detailId: any = ''
  //表格加载中的状态
  loading: boolean = true

  created() {
    this.getList(1)
  }

  // 获取数据
  async getList(page) {
    let vm: any = this
    // let params = {
    //   pageNo: page,
    //   pageSize: vm.pageSize,
    // }
    let params={
      "filter":{
      'street_code':10001,'type':'n'
      },
      "range": [0, 10]
     }
   let out:any=await homeIndex(params);
   console.log(out)
  }

  // 改变页码
  changePage(index) {
    this.getList(index)
  }

  // 每页展示的条数
  changePageSize(index) {
    this.pageSize = index
    this.getList(index)
  }

  // 添加活动
  digAdd() {
    let vm = this
    vm.isAdd = false
    vm.getList(vm.pageNo)
  }

  // 活动详情
  openDetails() {
    let vm = this;
    // vm.detailId = row.id;
    vm.isDetail = true;
  }

  // 打开活动编辑
  openEdit(row) {
    // let vm = this;
    //     vm.editId = row.id;
    //     vm.isEdit = true;
  }

  // 编辑确定
  digEdit() { }

  // 活动删除
  openDelete() { }

  // 商品管理
  openCommoditManage() { }
  // 优惠卷管理
  openCouponManage() {

  }
  //标签管理
  openLableManage() {

  }

}
